
import { commands, window, Selection, env, Uri, type ExtensionContext } from 'vscode'
import { defaultURL } from './env'

// 定义一个函数，用于打开文档页面
function openDocumentation() {
	env.openExternal(Uri.parse(`${defaultURL}`))
}

function moveCursor(characterDelta: number) {
	const active = window.activeTextEditor!.selection.active!
	const position = active.translate({ characterDelta })
	window.activeTextEditor!.selection = new Selection(position, position)
}


export function registerCommands(context: ExtensionContext) {
	context.subscriptions.push(
		commands.registerCommand('proiview.move-cursor', moveCursor),
		commands.registerCommand('proiview.open-documentation', () => {
			openDocumentation()
		}),
	);
}